<%@ page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/base/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<link href="${ctx}/css/main.css" rel="stylesheet" type="text/css" />
	</head>
	<script language="javascript">
		var message = '${message}';
		if(message != ''){
			alert(message);
		}
		function submitAction(actionName){
			document.roleForm.action = actionName ;
			document.roleForm.submit();
		}
		
		function doDelete(action,id){
			if(confirm('是否确认删除？')){
				location.href = "${ctx}/" + action + "?roleId=" + id ;
			}
		}
		
		function saveAction(action) {
			if(document.getElementById('roleName').value == '') {
				alert('请输入角色名称');
				return false;
			}
			submitAction(action)
		}
	</script>
	
	<body>
		<form method="post" action="" name="roleForm">
			<table border="0" cellspacing="1" cellpadding="3" align="center" width="100%">
				<tr>
					<td class="td11" align="left" colspan="4">
						<input type="button" name="save" value="保存" onClick="saveAction('saveRole.ac');">
						<c:if test="${!empty role.id}">
							&nbsp;&nbsp;<input type="button" name="delete" value="删除" onClick="doDelete('deleteRole.ac','${role.id}');">
						</c:if>
						&nbsp;&nbsp;<input type="button" name="back" value="返回" onClick="submitAction('roleManage.ac');">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						角色名称 <span style="color:red;vertical-align:middle;">*</span> 
					</td>
					<td width="30%" class="td2">
						<input type="hidden" name="id" size="32" value="${role.id}">
						<c:if test="${empty role.id}">
							<input type="text" name="roleName" size="32" value="${role.roleName}">
						</c:if>
						<c:if test="${!empty role.id}">
							<input type="text" readonly="readonly" style="color:grey" name="roleName" size="32" value="${role.roleName}">
						</c:if>
					</td>
					<td width="20%" class="td2">
						
					</td>
					<td width="30%" class="td2">
						
					</td>
				</tr>
			</table>
			<BR>
			<table border="0" cellspacing="1" cellpadding="3" align="center" width="80%">
				<c:forEach var="menu" items="${roleMenuList}" varStatus="status">
					<tr>
								<c:if test="${menu.checkFlag == 1}">
									<input type="checkbox" name="checkList" checked="true" value="${menu.id}">
									&nbsp;&nbsp;&nbsp;&nbsp;${menu.menuName}
								</c:if>
								<c:if test="${menu.checkFlag == 0}">
									<input type="checkbox" name="checkList" value="${menu.id}">
									&nbsp;&nbsp;&nbsp;&nbsp;${menu.menuName}
								</c:if>
					</tr>
				</c:forEach>
			</table>
		</form>
	</body>
</html>